/*******************************************************************************
				FIGURE 4
*******************************************************************************/

*AGE IV, COWORKERS
*FIGURE 4: SENSITIVITY ANALYSIS.

cap{
use "$data/fig4.dta", clear
local xi edad edad2 sexo lnw anos_educ puntaje
local xg m_l_sexo m_l_puntaje m_l_anos_educ m_l_lnw

foreach delta of numlist 253(7)400{
qui ivreg sej2012 `xi' `xg' (lnet = zlnet) if h==`delta', cluster(rut_emp)
parmest, saving("$results/window_`delta'.dta", replace) idnum(`delta') level(90 95)
}
use "$results/window_253.dta", clear
cap erase "$results/window_253.dta"
foreach delta of numlist 260(7)400{
append using "$results/window_`delta'.dta"
cap erase "$results/window_`delta'.dta"
}
keep if parm=="lnet"

tw (connected estimate idnum, mcolor(black) lcolor(black)) /// 	
	(line min90 idnum, lpattern(dash) lcolor(black)) ///
	(line max90 idnum, lpattern(dash) lcolor(black)), ///
	ytitle("Estimated peer effect {&beta}") ///
	ylabel(-0.2(0.2)1, format(%3.2fc)) ymlabel(-0.2(0.1)1,nolabel) /// 
	yline(0, lc(black)) ///
	xtitle("Width of {&Delta} (in days)") ///
	xline(260,lp(dash) lc(black)) ///
	xlabel(250(50)400) xmlabel(250(10)400,nolabel) /// 	
	legend(off) ///
	scheme(s1color) ///
	name("Figure4", replace)
	graph export "$results/Figure4.pdf", replace
	clear
}
